<template>
  <a-select placeholder="请选择权限范围" v-model="innerValue" mode="multiple">
    <a-select-option v-for="item in options" :key="item.id" :value="item.id">
      {{ item.actionName }}
    </a-select-option>
  </a-select>
</template>
<script>
import {createModelForVue, createProps} from '@/utils';
import {createFormDefinition} from '@comp/hhd/design/FormDesigner/types';

export default {
  name: 'FormCheckActionsSelector',
  model: createModelForVue(),
  props: {
    value: createProps(String),
    formDefinition: createProps(Object, createFormDefinition)
  },
  computed: {
    options() {
      return this.formDefinition && this.formDefinition.actions || [];
    },
    innerValue: {
      get() {
        if (!this.value) return undefined;
        return this.value.split(',');
      },
      set(v) {
        if (!v || !v.length) {
          this.$emit('change', undefined);
          return;
        }

        this.$emit('change', v.toString());
      },
    },
  }
};
</script>